<h2 class="title">Die Bauarbeiter</h2>
<div class="content"> <!-- Content start -->
<%= link_to 'Neuer Bauarbeiter', new_worker_path if @user.is_schorsch? %>
<table>
  <tr>
    <th>Name</th>
    <th>Routen</th>
    <th>Neuste</th>
    <th>Leichteste</th>
    <th>Schwerste</th>
    <th></th>
    <th></th>
  </tr>

<% @workers.each do |worker| %>
  <tr>
    <td><%= worker.name %></td>
    <td><%= worker.routes.size %></td>
    <td><%= worker.routes.sort{|x, y| x.created_at <=> y.created_at}.first.build if worker.routes.size > 0 %></td>
    <td><%= worker.routes.sort{|x, y| x.grade <=> y.grade}.first.grade.grade if worker.routes.size > 0 %></td>
    <td><%= worker.routes.sort{|x, y| y.grade <=> x.grade}.first.grade.grade if worker.routes.size > 0 %></td>
    <td><%= link_to 'Anzeigen', worker %></td>
    <td><% if @user.is_admin? || @user == worker %><%= link_to 'Editieren', edit_worker_path(worker) %><% end %></td>
    <td><% if @user.is_admin? %><%= link_to 'Löschen', worker, :confirm => 'Are you sure?', :method => :delete %><% end %></td>
  </tr>
<% end %>
</table>

<br />

</div>
